package com.abu.message.utils;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class SmsTemplate {

    public static Integer sendMsg(String phone, String code) throws ClientException {
        DefaultProfile profile = DefaultProfile.getProfile("cn-qingdao", "LTAI5tJ2zZh6R1kFnimkcb4M", "jELl8cTtRissQOdlRLCKgfeSqbgeGQ");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("PhoneNumbers", phone);
        request.putQueryParameter("SignName", "乐优商城");
        request.putQueryParameter("TemplateCode", "SMS_182674528");
        request.putQueryParameter("TemplateParam", "{\"code\": " + code + "}");
        CommonResponse response = client.getCommonResponse(request);
        return response.getHttpStatus();
    }
}